home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 781 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.2 KB

  1. Path: engnews1.Eng.Sun.COM!usenet
  2. From: elesueur@ens-lyon.fr (Emmanuel Lesueur)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Static member functions and overloadin
  5. Date: 19 Mar 1996 16:05:51 GMT
  6. Organization: Ecole Normale Superieure de Lyon, France
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Distribution: world
  9. Message-ID: <4im79s$e3b@cri.ens-lyon.fr>
  10. References: <4ikob2$bs1@engnews1.Eng.Sun.COM>
  11. Reply-To: elesueur@ens-lyon.fr
  12. NNTP-Posting-Host: taumet.eng.sun.com
  13. X-Nntp-Posting-Host: maxime.ens-lyon.fr
  14. Content-Length: 1322
  15. X-Lines: 30
  16.  
  17.  
  18. In article <4ikob2$bs1@engnews1.Eng.Sun.COM>, clamage@Eng.Sun.COM (Steve Clamage) writes:
  19. >I think the rules in the draft make sense in this case, if only because it
  20. >is bound to be confusing to have a pair of overloaded functions like these.
  21. >I don't think it is obvious that either function is the one intended, so
  22. >the ambiguity ensures you specify precisely what you intend. That is,
  23. >you give the functions different names, or incompatible parameter lists,
  24. >or write the call more explicitly, for example:
  25. >    b.f(int(c))
  26. >    ((A&)b).f(c)
  27. >If you have to write calls like this, I would seriously consider whether
  28. >it makes sense to overload the functions.
  29.  
  30. I agree that using this kind of overloading is a bad idea (BTW, this is
  31. not a real life example, just a test for my compiler).
  32.  
  33. However, the fact that the above call is ambiguous is not logical, IMHO,
  34. because it wouldn't be ambiguous if 'b' had type 'A' instead of 'B'. 
  35. Deriving a class should not turn an unambiguous call into an ambiguous
  36. one. A derived class is expected to have the same behaviour as its base.
  37.  
  38. Why not have the standard say something like: the implicit object
  39. parameter for a static member function of class A has type 
  40. 'const volatile A&' ?
  41.  
  42. ___________________________________________________
  43.  
  44. Emmanuel Lesueur  -   elesueur@ens-lyon.fr
  45.  
  46.  
  47.  
  48.  
  49. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your
  50.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  51.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  52.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  53.   Comments? mailto:std-c++-request@ncar.ucar.edu
  54. ]
  55.